/*
 * ArenaState.cpp
 *
 *  Created on: 30/07/2010
 *      Author: alex
 */

#include "control/CollisionManager.h"
#include "core/utils.h"
#include "ArenaState.h"

using namespace utils;
using std::list;


ArenaState::ArenaState() :
background("img/backgrounds/arena.jpg") {
	for (unsigned i = 0; i < numPlayers; ++i) {
		Player* aux = new Catherine(i);
		aux->setX(150 * i).setY(150 * i);
		dragons.push_back(aux);
		collisionManager.add(COLLIDING_PLAYER, aux);
	}
	rectCenter = dragons.front()->getPointer();
}


ArenaState& ArenaState::update(unsigned  dt) {
	for (list<Player*>::iterator it = dragons.begin(); it != dragons.end(); ++it) {
		(*it)->update(dt);
	}
	collisionManager.treatCollisions(dt);
	return *this;
}


void ArenaState::render(SDL_Surface* screen) {
	background.render(screen);
	for (list<Player*>::iterator it = dragons.begin(); it != dragons.end(); ++it) {
		(*it)->render(screen);
	}
}
